<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <input type="number" v-model="count" />
      <h2>{{count}}</h2>
      <h2>double: {{doubleCount}}</h2>
      <hr />
      <button @click="changeCount">手动修改 computed 的值</button>
    </div>
    <script src="../packages/vue.min.js"></script>
    <script>
      new Vue({
        data() {
          return {
            count: 100,
          }
        },
        methods: {
          changeCount() {
            this.doubleCount = 18
          },
        },
        computed: {
          // doubleCount() {
          //   console.log(this)
          //   return this.count * 2
          // },
          // doubleCount: vm => {
          //   console.log(vm)
          // },
          // set / get
          doubleCount: {
            get() {
              return this.count * 2
            },
            set(val) {
              this.count = val
            },
          },
        },
      }).$mount('#app')
    </script>
  </body>
</html>
